<template>
  <div>
	  
	  用户列表
    <el-row :gutter="10">
      <el-col :span="5"><el-input v-model="search.name" placeholder="请输入要查询的用户名"></el-input></el-col>
      <el-col :span="19">
        <el-button type="primary" icon="el-icon-search" plain @click="searchData()">快速查询</el-button>
      </el-col>
    </el-row>
    <el-table
      :data="result.tableData"
      style="width: 100%"
       @selection-change="handleSelectionChange"
    >
 
      <el-table-column
        label="序号"
        prop="id"
      >
      </el-table-column>
	  <el-table-column
	    label="档案编号"
	    prop="recordId"
	  >
	  </el-table-column>
	  <el-table-column
	    label="姓名"
	    prop="name"
	  >
	  </el-table-column>
	  <el-table-column
	    label="病因"
	    prop="cause"
	  >
	  </el-table-column>
	  <el-table-column
	    label="治疗处方"
	    prop="treatmentPres"
	  >
	  </el-table-column>
	  <el-table-column
	    label="主治医师"
	    prop="cureDoctor"
	  >
	  </el-table-column>
	  <el-table-column
	    label="开始时间"
	    prop="startTime"
	  >
	  </el-table-column>
	  <el-table-column
	    label="预计康复周期"
	    prop="expectRecover"
	  >
	  </el-table-column>
	 <el-table-column label="操作" width="220px">
	 			 
	 		 	 <template slot-scope="scope">	
	 		 	                 <template >
	 		 	                   <el-button
	 		 	                     size="mini"
									 type="success"
	 		 	                     @click="edit(scope.row.id)">修改</el-button>
	 		 	                   <el-button
	 		 	                     size="mini"
	 		 	                     type="primary"
	 		 	                     @click="del(scope.row.id)">删除</el-button>
	 		 	                   
	 		 	                 </template>
	 		 	               </template>
	 		 	</el-table-column>
	  
    
     
    
    </el-table>
    <el-pagination
      style="margin-top:20px;"
      background
      layout="prev, pager, next"
      :page-count="result.pages"
      :current-page.sync="query.pageNo"
      :page-size="query.pageSize"
      @current-change="getData()">
    </el-pagination>
	<el-dialog :title="title" :visible.sync="show" :close-on-click-modal="false" width="500px">
		<recure_planEdit v-if="show" :show.sync="show" @getData="getData()" :editid="editid">
		</recure_planEdit>
	</el-dialog>
	
   
  </div>
</template>

<script>
	import recure_planEdit from '@/views/recure_plan/edit'
	export default {
		name: 'recure_plan',
		components: {
			recure_planEdit,
		},
		data() {
			return {
				showNum: 0,
				editid: null,
				search: {
					name: ''
				},
				query: {
					name: '',
					pageNo: 1,
					pageSize: 8
				},
				result: {
					tableData: [],
					pages: 0
				},
				show: false,
				selectedrow: [],
				title: ''
			}
		},
		created() {
			this.getData()
		},
		methods: {
			getData() {
				this.axios.get('/recurePlan/list', response => {
					this.result.tableData = response.obj.records
					this.result.pages = response.obj.pages
					console.log(this.result.tableData)
				}, this.query)
			},
			searchData() {
				this.query.name = this.search.name
				this.query.pageNo = 1
				this.getData()
			},
			
			edit(id) {									
				this.title = '修改信息'
				this.editid = id
				this.showNum++;
				this.show = true
			},
			
			add() {
				this.title = '添加';
				this.editid = null;
				this.showNum++;
				this.show = true;
			},

			del(id) {
				this.axios.del('/recurePlan/del', response => {
					this.getData()
				}, {
					id: id
				})
			},
			handleSelectionChange(val) {
				// val参数为所有选中行的数据
				this.selectedrow = val
			},
			batchdel() {
				if (this.selectedrow.length === 0) {
					this.$message('没有任何被选中的数据');
				} else {
					const ids = []
					for (let i = 0; i < this.selectedrow.length; i++) {
						ids.push(this.selectedrow[i].id)
					}
					this.axios.del('/ums-user/batchdel', response => {
						this.getData()
					}, {
						ids: ids
					})
				}
			},
			
		}
			}
		
	
</script>
<style scoped>
</style>
